<template>
   <div class="cnyzs-error">
      <h1 v-if="error.statusCode != '404' ">{{ error.statusCode }}</h1>
      <a-image v-else src="/base/404.png"></a-image>
      <h2>{{ error.message }}</h2>
<!--      <div v-html="error.stack"></div>-->
     <a-button type="primary" shape="round" @click="backPage">返回首页</a-button>
   </div>
</template>
<script lang="ts" setup >
const props = defineProps({
   error: Object as any,
})
// const handleError = () => clearError({ redirect: '/' })

// onMounted(() => {
//    console.log(props.error);
// })

// 返回上一页，没有则返回首页
function backPage() {
   const router = useRouter()
   // 有上一页则返回
   if (window.history.state.back) {
      router.go(-1)
   } else {
      // 没有上一页则返回到首页
      router.replace({ path: '/' })
   }
}

</script>
<style lang="scss" scoped>
.cnyzs-error {
   width: 100%;
   height: 100vh;
   overflow: hidden;
   display: flex;
   flex-direction: column;
   justify-content: center;
   align-items: center;
}
</style>